package cn.iocoder.yudao.module.system.service.config;

import cn.iocoder.yudao.module.system.controller.admin.messageInfo.vo.FeedBackVO;
import cn.iocoder.yudao.module.system.dal.dataobject.config.InfraConfigDO;
import cn.iocoder.yudao.module.system.dal.mysql.config.InfraConfigMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 参数配置 Service 实现类
 */
@Service
@Slf4j
@Validated
public class InfraConfigServiceImpl implements InfraConfigService {

    @Resource
    private InfraConfigMapper infraConfigMapper;



    @Override
    public InfraConfigDO getConfig(Long id) {
        return infraConfigMapper.selectById(id);
    }

    @Override
    public String getConfigByKey(String key) {
        InfraConfigDO configDO = infraConfigMapper.selectByKey(key);
        if(null==configDO){
            return null;
        }
        return configDO.getValue();
    }

    @Override
    public String getConfigByKey(String key, String defValue) {
        String sValue = this.getConfigByKey(key);
        if(StringUtils.isBlank(sValue)){
            return defValue;
        }
        return sValue;
    }

    @Override
    public int updateJobDayFlow(Integer dayFlow) {
       return infraConfigMapper.updateJobDayFlow(dayFlow);
    }

    @Override
    public List<Long> getJobByTimingStatus(Integer timingStatus,String fixedTime) {
        return infraConfigMapper.getJobByTimingStatus(timingStatus,fixedTime);
    }

    @Override
    public int updateJobInfoById(String status, List<Long> list) {
        return infraConfigMapper.updateJobInfoById(status,list);
    }

    @Override
    public int updateProjectScheduleTypeById(Long id, Integer scheduleType) {
        infraConfigMapper.updateProjectScheduleTypeById(id,scheduleType);
        return 1;
    }

    @Override
    public List<Map<String,Object>> getScheduleTypeData() {
        return infraConfigMapper.getScheduleTypeData();
    }

    @Override
    public void updateProjectFeedStatus(List<Long> ids) {
        infraConfigMapper.updateProjectFeedStatus(ids);
    }

    @Override
    public List<FeedBackVO> getEntryStudent() {
        return infraConfigMapper.getEntryStudent();
    }

    @Override
    public void saveProjectFeedBack(List<FeedBackVO> list) {
        infraConfigMapper.saveProjectFeedBack(list);
    }
}
